class code4 {
    public int minimumTotal(List<List<Integer>> triangle) {
        int sz = triangle.size();

        int[] dp = new int[sz+1];

        for(int i=sz-1;i>=0;i--) {
            List<Integer> rows = triangle.get(i);
            for(int j=0;j<rows.size();j++) {
                dp[j] = Math.min(dp[j],dp[j+1]) + rows.get(j);
            }
        }

        return dp[0];
    }
}